list-[id].vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <section class="book_son_right clearfix">
  13. <div class="book_son_right_ul clearfix">
  14. <div class="book_son_right_li clearfix" v-for="(item, index) in newsDetail" :key="index">
  15. <div class="book_son_right_li_img">
  16. <img class="book_son_right_li_img" :src="item.img_url" :title="item.title"
  17. v-if="item.img_url">
  18. </div>
  19. <div class="book_son_right_li_in clearfix">
  20. <h4 class="book_son_right_li_h4 dot1">{{ item.title }}</h4>
  21. <div class="book_son_right_li_dot3 dot3">
  22. {{ item.description }}
  23. </div>
  24. <NuxtLink :href="`/${item.pinyin}/${item.id}.html`" class="book_son_right_li_btn"
  25. :title="item.name">
  26. 查看详情
  27. </NuxtLink>
  28. </div>
  29. </div>
  30. </div>
  31. </section>
  32. <!-- 分页器 -->
  33. <div class="pagination phone_none" v-if="total > 0">
  34. <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
  35. :page-size="pageSize" prev-text="上一页" next-text="下一页" @change="changePage" />
  36. </div>
  37. </div>
  38. <div class="innerRight">
  39. <div class="rightMenuTitle">
  40. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  41. </div>
  42. <ul>
  43. <li v-for="(item, index) in bottomMenu" :key="index">
  44. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  45. v-if="item.category_id == pageId" class="active">
  46. {{ item.alias }}
  47. </NuxtLink>
  48. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  49. v-else-if="item.category_id != pageId">
  50. {{ item.alias }}
  51. </NuxtLink>
  52. </li>
  53. </ul>
  54. </div>
  55. <div class="pagination pc_none" v-if="total > 0">
  56. <el-pagination size="small" background layout=" pager " :total="total" class="mt-4" pager-count="5"
  57. :page-size="pageSize" @change="changePage" />
  58. </div>
  59. <div style="clear: both;"></div>
  60. </div>
  61. </div>
  62. <!-- 广告二 -->
  63. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  64. <!-- 页面底部 -->
  65. <HomeFoot1></HomeFoot1>
  66. </template>
  67. <script setup>
  68. //1.页面依赖 start ---------------------------------------->
  69. import { ElPagination } from 'element-plus'
  70. import { ArrowRight } from '@element-plus/icons-vue'
  71. import { ref, onMounted } from 'vue';
  72. //获得跳转过来的id
  73. const route = useRoute();
  74. //获得当前的完整路径
  75. const fullPath = route.path;
  76. //拆分,取出来中间这一段,然后提取数字部分
  77. const segments = fullPath.split('/');
  78. const targetSegment2 = segments[2];
  79. const targetSegment1 = segments[1];
  80. //const numberPart = targetSegment2.match(/\d+$/)?.[0];
  81. let articleId;
  82. let pageId;
  83. let routeId
  84. let activeId = parseInt(route.params.id);
  85. console.log('activeId', activeId);
  86. //通过导航路径反向查询导航id
  87. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  88. method: 'GET',
  89. query: {
  90. 'pinyin': targetSegment1 + '/' + targetSegment2,
  91. },
  92. });
  93. if (getRouteId.code == 200) {
  94. articleId = getRouteId.data.id;
  95. pageId = getRouteId.data.category_id;
  96. } else {
  97. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  98. console.log("错误位置:通过url路径查询导航池id")
  99. console.log("后端错误反馈:", getRouteId.message)
  100. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  101. }
  102. //通过导航路径反向查询导航id
  103. const getRouteId1 = await requestDataPromise('/web/getWebsiteRoute', {
  104. method: 'GET',
  105. query: {
  106. 'pinyin': targetSegment1,
  107. },
  108. });
  109. if (getRouteId1.code == 200) {
  110. routeId = getRouteId1.data.category_id;
  111. } else {
  112. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  113. console.log("错误位置:通过url路径查询导航池id")
  114. console.log("后端错误反馈:", getRouteId1.message)
  115. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  116. }
  117. //面包屑导航
  118. const parent_name = ref("");
  119. const parent_id = ref("");
  120. const parent_pinyin = ref("");
  121. let getParentNav = async () => {
  122. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  123. method: 'GET',
  124. query: {
  125. 'catid': routeId,
  126. },
  127. });
  128. if (listData.code == 200) {
  129. parent_name.value = listData.data.alias;
  130. parent_id.value = listData.data.parent_id;
  131. parent_pinyin.value = listData.data.aLIas_pinyin;
  132. } else {
  133. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  134. console.log("错误位置:获取面包屑导航")
  135. console.log("后端错误反馈:", listData.message)
  136. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  137. }
  138. }
  139. //获得父级栏目详情
  140. getParentNav();
  141. //1.页面依赖 end ---------------------------------------->
  142. //2.页面数据 start ---------------------------------------->
  143. //广告列表
  144. const adList = ref([]);
  145. let adImg1 = ref([]);
  146. let adImg2 = ref([]);
  147. async function getAdData() {
  148. const adData = await requestDataPromise('/web/getWebsiteAdvertisement', { method: 'GET', query: { 'ad_tag': 'PAGE' } });
  149. adList.value = adData.data;
  150. if (adData.code == 200) {
  151. for (let item of adData.data) {
  152. if (item.ad_tag == 'PAGE_0001') {
  153. adImg1.value = item;
  154. }
  155. if (item.ad_tag == 'PAGE_0002') {
  156. adImg2.value = item;
  157. }
  158. }
  159. } else {
  160. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  161. console.log("错误位置:获取详情页广告列表")
  162. console.log("后端错误反馈:", adData.message)
  163. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  164. }
  165. }
  166. getAdData();
  167. const newsDetail = ref({})
  168. const bottomMenu = ref([]);
  169. const total = ref(0);//总条数
  170. const page = ref(1);//当前页码
  171. const pageSize = ref(10); //每页显示的条数
  172. async function getPageMenu() {
  173. const mkdata = await requestDataPromise('/web/getWebsiteBookList', {
  174. method: 'GET',
  175. query: {
  176. 'id': pageId,
  177. 'page': page.value,
  178. 'pageSize': pageSize.value,
  179. },
  180. });
  181. bottomMenu.value = mkdata.data.category;
  182. newsDetail.value = mkdata.data.books;
  183. total.value = mkdata.data.count;
  184. }
  185. getPageMenu();
  186. //2.页面数据 end ---------------------------------------->
  187. //3.分页器 start ---------------------------------------->
  188. //分页事件
  189. let changePage = (value) => {
  190. console.log("当前页码", value);
  191. page.value = value;
  192. getPageMenu()
  193. }
  194. //3.分页器 end ---------------------------------------->
  195. //4.设置seo信息 start---------------------------------------->
  196. //4.1 设置seo信息
  197. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  198. method: 'GET',
  199. query: {
  200. 'catid': pageId
  201. },
  202. });
  203. if (setData.code == 200) {
  204. let seoTitle = setData.data.seo_title;
  205. let seoDescription = setData.data.seo_description;
  206. let seoKeywords = setData.data.seo_keywords;
  207. let seoSuffix = setData.data.suffix;
  208. let seoName = setData.data.website_name;
  209. useSeoMeta({
  210. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  211. meta: [
  212. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  213. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  214. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  215. ]
  216. });
  217. } else {
  218. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  219. console.log("错误位置:设置列表页面SEO数据")
  220. console.log("后端错误反馈:", setData.message)
  221. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  222. }
  223. //4.设置seo信息 end---------------------------------------->
  224. onMounted(async () => {
  225. //从客户端获取行政职能部门 加快打开速度
  226. const { $webUrl, $CwebUrl } = useNuxtApp();
  227. //广告1
  228. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_list_0001`
  229. const responseAd1 = await fetch(url, {
  230. headers: {
  231. 'Content-Type': 'application/json',
  232. 'Userurl': $CwebUrl,
  233. 'Origin': $CwebUrl
  234. }
  235. });
  236. const resultAd1 = await responseAd1.json();
  237. adImg1.value = resultAd1.data[0];
  238. //广告2
  239. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_list_0002`
  240. const responseAd2 = await fetch(url2, {
  241. headers: {
  242. 'Content-Type': 'application/json',
  243. 'Userurl': $CwebUrl,
  244. 'Origin': $CwebUrl
  245. }
  246. });
  247. const resultAd2 = await responseAd2.json();
  248. adImg2.value = resultAd2.data[0];
  249. })
  250. </script>
  251. <style lang="less" scoped>
  252. @import '@/assets/css/shukanList.less';
  253. </style>
  254. <style lang="less" scoped>
  255. @media screen and (min-width:801px){/*pc*/
  256. .pc_none{display:none;}
  257. }
  258. @media screen and (max-width:800px){/*ipad_phone*/
  259. .newsDetail {margin-top:11px;}
  260. .newsDetail .inner{width:92%;margin:0px auto 11px;overflow:hidden;}
  261. .newsDetail .inner .innerRight{width:24%; }
  262. .newsDetail .inner .innerRight .rightMenuTitle{width:100%;height:auto; background-size:100% 155%; margin-bottom:11px;}
  263. .newsDetail .inner .innerRight .rightMenuTitle a{display:block;width:100%;height:auto;line-height:33px;font-size:14px;text-align:center;}
  264. .newsDetail .inner .innerRight ul{display:block;width:100%;height:auto;}
  265. .newsDetail .inner .innerRight ul li{display:block;width:100%;height:auto;}
  266. .newsDetail .inner .innerRight ul li a {line-height:20px;height:auto;font-size:12px;margin-bottom:5px;padding: 6px 2px;box-sizing:border-box;
  267. border-left: 2px solid #489d97;}
  268. .newsDetail .inner .innerLeft{width:72%;overflow:hidden;margin:0 ;}
  269. .newsDetail .inner .innerLeft .book_son_right{float:none;width:100%;overflow:hidden;margin-bottom:22px;min-height:auto;}
  270. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li>.book_son_right_li_img{width:30%;margin-right:4%;height:auto;}
  271. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li>.book_son_right_li_img .book_son_right_li_img{width:100%;height:27vw; }
  272. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_in{width:auto;float:none; }
  273. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_h4{margin-top:0px;font-size:14px;
  274. line-height:20px;
  275. height:40px;
  276. word-break: normal;
  277. white-space: break-spaces;
  278. overflow: hidden;
  279. text-overflow: unset;
  280. display:-webkit-box!important;-webkit-box-orient:vertical;-webkit-line-clamp:2;
  281. }
  282. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_dot3{line-height:20px;height:40px;font-size:14px;-webkit-line-clamp:2;display:none;}
  283. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_btn{
  284. padding:0px 8px;margin-top:8px;height:28px;line-height:28px;font-size:12px;
  285. position:absolute;bottom:0px;left:37%;
  286. }
  287. .book_son_right_ul{min-height:540px;}
  288. .newsDetail{margin-bottom:11px;}
  289. .pagination{margin-top:11px;}
  290. .part_2{height:11px;}
  291. .phone_none{display:none;}
  292. }
  293. </style>